package Commandes;

import java.util.Stack;


public class InvokerCommande {
    
    private static InvokerCommande instance;
    private Stack pile;
    
    private InvokerCommande() {
        
        pile = new Stack();
    }
    
    public static InvokerCommande getInstance(){
        
        if(instance==null)instance = new InvokerCommande();
        
        return instance;
    }
    
    public void executerUneCommande(Commande c){
        
        if(c.executer()){
            
            pile.push(c);
        }
    }
    
    public void cancelCommande(){
        
        if(!pile.empty()){
            
            Commande c=(Commande)pile.pop();
            c.cancel();
        }
    }
}
